<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<t:link />
<title>修改用户信息</title>
</head>


<body>
	<div class="row">
		<div class="col-lg-12 col-sm-12 col-xs-12">
			<div class="widget  dev">
				<div class="widget-body">
					<div id="horizontal-form">
						<form class="form-horizontal" role="form" action="" method="post">
							<input type="hidden" id="id" name="id" value="${user.id}">
							<div class="form-group">
								<label for="username"
									class="col-sm-2 control-label no-padding-right">用户名</label>
								<div class="col-sm-6">
									<input class="form-control" id="username" placeholder=""
										name="username" type="text" value="${user.username}">
								</div>
							</div>
							<div class="form-group">
								<label for="nickname"
									class="col-sm-2 control-label no-padding-right">昵称</label>
								<div class="col-sm-6">
									<input class="form-control" id="nickname" placeholder=""
										name="nickname" type="text" value="${user.nickname}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>
							<div class="form-group">
								<label for="email"
									class="col-sm-2 control-label no-padding-right">邮箱</label>
								<div class="col-sm-6">
									<input class="form-control" id="email" placeholder=""
										name="email" type="text" value="${user.email}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>
							<div class="form-group">
								<label for="phone"
									class="col-sm-2 control-label no-padding-right">联系电话</label>
								<div class="col-sm-6">
									<input class="form-control" id="phone" placeholder=""
										name="phone" type="text" value="${user.phone}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>
							<div class="form-group">
								<label for="qq" class="col-sm-2 control-label no-padding-right">QQ</label>
								<div class="col-sm-6">
									<input class="form-control" id="qq" placeholder="" name="qq"
										type="text" value="${user.qq}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>
							<div class="form-group">
								<label for="weixin"
									class="col-sm-2 control-label no-padding-right">微信</label>
								<div class="col-sm-6">
									<input class="form-control" id="weixin" placeholder=""
										name="weixin" type="text" value="${user.weixin}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>

							<div class="form-group">
								<label for="isopen"
									class="col-sm-2 control-label no-padding-right">是否公开</label>
								<div class="col-sm-6">
									公开:<input id="open1" name="isopen" type="radio" value="0"> 不公开:<input
										id="open2" name="isopen" type="radio" value="1">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>

							<div class="form-group">
								<label for="memo"
									class="col-sm-2 control-label no-padding-right">个人简介</label>
								<div class="col-sm-6">
									<input class="form-control" id="memo" placeholder=""
										name="memo" type="text" value="${user.memo}">
								</div>
								<p class="help-block col-sm-4 red"></p>
							</div>


							<div class="form-group">
								<div class="col-sm-offset-2 col-sm-10">
									<button id="button" type="button" class="btn btn-default">保存信息</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>


</body>


<script>

	$().ready(function(){
		
		//初始化是否公开数据
		initIsOpen()
	})
	function initIsOpen(){
		var tt =$("#isopen").val();
		if(0==tt){
			$("#open1").attr("checked","checked");
		}else{
			$("#open2").attr("checked","checked");
		}
	}

	$("#button").click(
			function() {
				var user = new Object();
				user.id = $("#id").val();
				user.phone = $("#phone").val();
				user.username = $("#username").val(); user.nickname = $(
						"#nickname").val(); user.email = $("#email").val();
						user.qq = $("#qq").val(); user.weixin = $("#weixin")
								.val(); user.isopen=$('input:radio[name="isopen"]:checked').val();
						user.memo = $("#memo").val();
				$.ajax({
					url : "${pageContext.request.contextPath}/user/userupdate",
					type : "POST",
					data : {
						user : JSON.stringify(user)
					},
					success : function(data) {
						alert("保存成功!");
						window.open(
								"${pageContext.request.contextPath}/user/user",
								"_self");
					},
					error : function(data) {
						alert("保存失败!");
					}
				})

			})
</script>

</html>